{block name="circle_layout"}
	{include file="common:common_layout"}
{/block}
{extend name="common/layout" /}
{block name="style"}{/block}
{block name="content"}
<div class="base-layout">
    <div class="mainbox">
        {include file="circle:manage:top" /}
        
        <form id="circle_form" action="{:url('circle/manage/index')}?c_id={$c_id}" method="post" class="base-form-style">
            <input type="hidden" value="ok" name="form_submit">
            <dl>
                <dt>圈子描述：</dt>
                <dd>
                    <textarea name="c_desc" id="c_desc" class="textarea w500 h100"><?php echo $circle_info['circle_desc'];?></textarea>
                    <span class="count" id="desccharcount"></span> </dd>
            </dl>
            <dl>
                <dt>圈子公告：</dt>
                <dd>
                    <textarea name="c_notice" id="c_notice" class="textarea w500 h100"><?php echo $circle_info['circle_notice'];?></textarea>
                    <span class="count" id="noticecharcount"></span> </dd>
            </dl>
            <dl>
                <dt>圈子LOGO：</dt>
                <dd>
                    <div class="picture"><img id="view_img" src="<?php echo circleLogo($circle_info['circle_id']);?>"/></div>
                    <div class="upload-btn"> <a href="javascript:void(0);"> <span>
            <input type="file" name="c_img" id="c_img" multiple="" file_id="0" class="file" size="1" hidefocus="true" />
            </span>
                        <div class="upload-button"><i></i>图片上传</div>
                        <input id="submit_button" style="display:none" type="button" value="&nbsp;" onClick="submit_form($(this))" />
                    </a></div>
                </dd>
            </dl>
            <dl>
                <dt>申请审核：</dt>
                <dd>
                	<h5 class="mr20">是
                    <input type="radio" name="c_joinaudit" value="1" <?php if($circle_info['circle_joinaudit'] == 1){?>checked="checked"<?php }?> />
                    </h5>
                    <h5>否
                    <input type="radio" name="c_joinaudit" value="0" <?php if($circle_info['circle_joinaudit'] == 0){?>checked="checked"<?php }?> />
                    </h5> 
                </dd>   
            </dl>
            <dl style="border-bottom: none;">
                <dt>申请管理：</dt>
                <dd>
                	<h5 class="mr20">是
                    <input type="radio" name="c_mapply" value="1" <?php if($circle_info['mapply_open'] == 1){?>checked="checked"<?php }?> />
                    </h5>
                    <h5>否
                    <input type="radio" name="c_mapply" value="0" <?php if($circle_info['mapply_open'] == 0){?>checked="checked"<?php }?> />
                    </h5>
                </dd>
            </dl>
            <dl>
                <dt></dt>
                <dd><select name="c_ml" class="mr10">
                    <option value="0">没有要求</option>
                    <?php for($i=1; $i<=16; $i++){?>
                    <option value="<?php echo $i;?>" <?php if($circle_info['mapply_ml'] == $i){?>selected="selected"<?php }?>><?php echo $ml_info['ml_'.$i].'&nbsp;LV'.$i;?></option>
                    <?php }?>
                </select><span class="count">申请成为本圈管理员时所需要的会员等级限制。</span>

                </dd>
            </dl>
            <dl class="bottom">
                <dt>&nbsp;</dt>
                <dd><a href="Javascript: void(0)" class="submit-btn" nctype="submit-btn">提交设置</a></dd>
            </dl>
        </form>
    </div>
    <div class="sidebar">
        {include file="circle:manage:sidebar" /}

    </div>
</div>
<script type="text/javascript" src="__SITE_RESOURCE__/js/jquery.charCount.js"></script>
<script type="text/javascript" src="__SITE_RESOURCE__/js/ajaxfileupload/ajaxfileupload.js"></script>
<script type="text/javascript" src="__SITE_RESOURCE__/js/jquery.Jcrop/jquery.Jcrop.js"></script>
<link href="__SITE_RESOURCE__/js/jquery.Jcrop/jquery.Jcrop.min.css" rel="stylesheet" type="text/css" id="cssfile2" />
<script type="text/javascript" src="__SITE_RESOURCE__/js/jquery.validation.min.js"></script>
<script>
    //裁剪图片后返回接收函数
    function call_back(picname){
        $('#c_img').val('');
        $('#view_img').attr('src','<?php echo UPLOAD_SITE_URL.'/'.ATTACH_CIRCLE;?>/group/'+picname+'?'+Math.random());
    }
    $(function(){
        $('#c_img').change(uploadChange);
        function uploadChange(){
            var filepath=$(this).val();
            var extStart=filepath.lastIndexOf(".");
            var ext=filepath.substring(extStart,filepath.length).toUpperCase();
            if(ext!=".PNG"&&ext!=".GIF"&&ext!=".JPG"&&ext!=".JPEG"){
                alert("file type error");
                $(this).attr('value','');
                return false;
            }
            if ($(this).val() == '') return false;
            ajaxFileUpload();
        }
        function ajaxFileUpload()
        {
            $.ajaxFileUpload
            (
                    {
                        url:"<?php echo url('circle/cut/pic_upload');?>?form_submit=ok&uploadpath=<?php echo ATTACH_CIRCLE;?>/group",
                        secureuri:false,
                        fileElementId:'c_img',
                        dataType: 'json',
                        success: function (data, status)
                        {
                            if (data.status == 1){
                                ajax_form('cutpic','裁剪',"<?php echo url('circle/cut/pic_cut');?>?filename=<?php echo ATTACH_CIRCLE;?>/group/<?php echo intval(I('c_id'));?>.jpg&x=120&y=120&resize=1&url="+data.url,680);
                            }else{
                                alert(data.msg);
                            }
                            $('#c_img').bind('change',uploadChange);
                        },
                        error: function (data, status, e)
                        {
                            alert('上传失败');$('#c_img').bind('change',uploadChange);
                        }
                    }
            )
        };
        $('a[nctype="submit-btn"]').click(function(){
            $('#circle_form').submit();
        });
        $('#circle_form').validate({
            errorPlacement: function(error, element){
                $(element).parents('dd:first').children('.field_notice').html(error);
            },
            submitHandler:function(form){
                ajaxpost('circle_form', "<?php echo url('circle/manage/index');?>?c_id=<?php echo $c_id;?>", '', 'onerror');
            },
            rules : {
                c_desc : {
                    maxlength : 255
                },
                c_notice : {
                    maxlength : 255
                }
            },
            messages : {
                c_desc  : {
                    maxlength : '不能超过255个字符'
                },
                c_notice : {
                    maxlength : '不能超过255个字符'
                }
            }
        });
        //字符个数动态计算
        $("#c_desc").charCount({
            allowed: 255,
            warning: 10,
            counterContainerID:'desccharcount',
            firstCounterText:'还可以输入',
            endCounterText:'字',
            errorCounterText:'已经超出'
        });
        //字符个数动态计算
        $("#c_notice").charCount({
            allowed: 255,
            warning: 10,
            counterContainerID:'noticecharcount',
            firstCounterText:'还可以输入',
            endCounterText:'字',
            errorCounterText:'已经超出'
        });
    });
</script>
{/block}